<?php
    if(isset($_GET["table"])) {$table = $_GET["table"];} else{$table = "";}
    if(isset($_GET["ligne"])) {$ligne = $_GET["ligne"];} else{$ligne = "";}

    require_once './include/class.pdoSio.inc.php';
    
    if($table == "experience_prof") {
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteSelection("SELECT * FROM cv_experience_prof WHERE id_experience_prof = ".$ligne);
        
        echo "<div class='container basPage'><fieldset><legend>Modification de votre expérience professionnelle</legend><form id='modifier' action='./include/modifCV.php' method='POST' name='modifier'>
            <div class='row'><div class='span3 offset4'><div><label>Poste</label><input type='text' id='poste' name='poste' value=\"".htmlspecialchars($etudiants[0]['poste'])."\" /></div>
            <div><label>Année de début</label><input type='text' id='anneeDebut' name='anneeDebut' value='".$etudiants[0]['anneeDeb']."' /></div>
            <div><label>Année de fin</label><input type='text' id='anneeFin' name='anneeFin' value='".$etudiants[0]['anneeFin']."' /></div>
            <div><label>Fonction</label><input type='text' id='fonction' name='fonction' value=\"".htmlspecialchars($etudiants[0]['fonction'])."\" /></div><br></div>
            <input type='hidden' value='".$table."' name='table' id='table' />
            <input type='hidden' value='".$ligne."' name='ligne' id='ligne' />
            <div class='span3 offset5'><div><input type='submit' /></div></div></div></fieldset>
        </form>";
    } elseif ($table == "formation") {
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteSelection("SELECT * FROM cv_formation WHERE id_formation = ".$ligne);
        
        echo "<div class='container basPage'><fieldset><legend>Modification de votre formation</legend><form id='modifier' action='./include/modifCV.php' method='POST' name='modifier'>
            <div class='row'><div class='span3 offset4'><div><label>Diplôme</label><input type='text' id='Diplome' name='Diplome' value=\"".htmlspecialchars($etudiants[0]['Diplome'])."\" /></div>
            <div><label>Année de début</label><input type='text' id='AnneeDebut' name='AnneeDebut' value='".$etudiants[0]['AnneeDeb']."' /></div>
            <div><label>Année de fin</label><input type='text' id='AnneeFin' name='AnneeFin' value='".$etudiants[0]['AnneeFin']."' /></div>
            <div><label>Etablissement</label><input type='text' id='Etab' name='Etab' value=\"".htmlspecialchars($etudiants[0]['Etab'])."\" /></div><br></div>
            <input type='hidden' value='".$table."' name='table' id='table' />
            <input type='hidden' value='".$ligne."' name='ligne' id='ligne' />
            <div class='span3 offset5'><div><input type='submit' /></div></div></div></fieldset>
        </form>";
    } elseif ($table == "informatique") {
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteSelection("SELECT * FROM cv_informatique WHERE id_informatique = ".$ligne);
        
        echo "<div class='container basPage'><fieldset><legend>Modification de votre compétence informatique</legend><form id='modifier' action='./include/modifCV.php' method='POST' name='modifier'>
            <div class='row'><div class='span3 offset4'><div><label>Compétence</label><input type='text' id='competence' name='competence' value=\"".htmlspecialchars($etudiants[0]['competence'])."\" /></div><br></div>
            <input type='hidden' value='".$table."' name='table' id='table' />
            <input type='hidden' value='".$ligne."' name='ligne' id='ligne' />
            <div class='span3 offset5'><div><input type='submit' /></div></div></div></fieldset>
        </form>";
    } elseif ($table == "interet") {
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteSelection("SELECT * FROM cv_interet WHERE id_interet = ".$ligne);
        
        echo "<div class='container basPage'><fieldset><legend>Modification de votre centre d'intérêt</legend><form id='modifier' action='./include/modifCV.php' method='POST' name='modifier'>
            <div class='row'><div class='span3 offset4'><div><label>Musique</label><input type='text' id='musique' name='musique' value=\"".htmlspecialchars($etudiants[0]['musique'])."\" /></div>
            <div><label>Sport</label><input type='text' id='sport' name='sport' value=\"".htmlspecialchars($etudiants[0]['sport'])."\" /></div>
            <div><label>Autre</label><input type='text' id='autre' name='autre' value=\"".htmlspecialchars($etudiants[0]['autre'])."\" /></div><br></div>
            <input type='hidden' value='".$table."' name='table' id='table' />
            <input type='hidden' value='".$ligne."' name='ligne' id='ligne' />
            <div class='span3 offset5'><div><input type='submit' /></div></div></div></fieldset>
        </form>";
    } elseif ($table == "langue") {
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteSelection("SELECT * FROM cv_langue WHERE id_langue = ".$ligne);
        
        echo "<div class='container basPage'><fieldset><legend>Modification de votre langue</legend><form id='modifier' action='./include/modifCV.php' method='POST' name='modifier'>
            <div class='row'><div class='span3 offset4'><div><label>Langue</label><input type='text' id='langue' name='langue' value=\"".htmlspecialchars($etudiants[0]['langue'])."\" /></div>
            <div><label>Niveau</label><input type='text' id='niveau' name='niveau' value=\"".htmlspecialchars($etudiants[0]['niveau'])."\" /></div><br></div>
            <input type='hidden' value='".$table."' name='table' id='table' />
            <input type='hidden' value='".$ligne."' name='ligne' id='ligne' />
            <div class='span3 offset5'><div><input type='submit' /></div></div></div></fieldset>
        </form>";
    } else {
        $pdo = PdoSio::getPdoSio();
        $etudiants = $pdo->requeteSelection("SELECT * FROM cv_photo WHERE id_cv_photo = ".$ligne);
        
        echo "<div class='container basPage'><fieldset><legend>Modification de votre photo</legend><form id='modifier' action='./include/modifCV.php' method='POST' name='modifier'>
            <div class='row'><div class='span3 offset4'><div><label>Photo</label>";file_put_contents("./styles/img/".$ligne.".png",$etudiants[0]['photo']);
            echo "<div class='photo'><img src='./styles/img/".$ligne.".png' /></div><br><input type='file' id='photo' name='photo' /></div><br></div>
            <input type='hidden' value='".$table."' name='table' id='table' />
            <input type='hidden' value='".$ligne."' name='ligne' id='ligne' />
            <div class='span3 offset5'><div><input type='submit' /></div></div></div></fieldset>
        </form>";
    }

